package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Repair;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RepairDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "维修名称")
    private String repairName;

    @ApiModelProperty(value = "生产单id")
    private Integer produceId;

    @ApiModelProperty(value = "退货单id")
    private Integer rejectId;

    @ApiModelProperty(value = "维修人")
    private Integer adminId;

    @ApiModelProperty(value = "维修部门")
    private Integer departmentId;

    @ApiModelProperty(value = "维修备注")
    private String remark;

    @ApiModelProperty(value = "维修单状态：0、待维修，1、维修完成")
    private Integer status;

    @ApiModelProperty(value = "送货标识:0、未完成，1、已完成")
    private Integer deliver;

    @ApiModelProperty(value = "预计完成维修时间")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date deadline;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "维修人")
    private String username;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "合同名称")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private String contractName;

    @ApiModelProperty(value = "维修产品详情")
    private List<RepairProductDTO> repairProductDTOS;


    public RepairDTO() {}

    public RepairDTO(Repair entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static RepairDTO convert(Repair entity) {
        return new RepairDTO(entity);
    }

    public static List<RepairDTO> convertList(List<Repair> list) {
        List<RepairDTO> resultList = new ArrayList<>();
        for (Repair entity : list) {
            resultList.add(new RepairDTO(entity));
        }
        return resultList;
    }}
